

const {getTop250Http,handleStar,handleStr,getBannerHttp} = require("../../utils/http")
Page({
   data:{
       banner:[],
       movies:[],
       star:""
   },
   onLoad(options){
    // console.log(options)


       wx.showLoading({
           title:"数据正在加载中"
       });
       getTop250Http().then(res=>{
           wx.hideLoading();
           this.handleTop250HttpData(res)
       });
       getBannerHttp().then(res=>{
        wx.hideLoading();
        this.handleBannerHttp(res)
       })

      },
      handleBannerHttp(res){
        // console.log(res.data.res)
        this.setData({
          banner:res.data.res
        })
      },
   handleTop250HttpData(res){
      // console.log(res.data)
      var star=[]
      res.data.forEach(item=>{
        var {rating}=item;
        // console.log(rating)
        star.push(rating)
      })
      
      this.setData({
          movies:res.data,
          star:handleStar(star)
      })
      // console.log(star)
      
   },
   
   handleItem(event){
       var {aid} = event.currentTarget.dataset;
       wx.navigateTo({
           url: `/pages/detail/detail?id=${aid}`
       });
   }

})